package com.jcfy.project.module.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jcfy.framework.aspectj.lang.annotation.Log;
import com.jcfy.framework.aspectj.lang.enums.BusinessType;
import com.jcfy.project.module.domain.TAccountDetail;
import com.jcfy.project.module.service.ITAccountDetailService;
import com.jcfy.framework.web.controller.BaseController;
import com.jcfy.framework.web.domain.AjaxResult;
import com.jcfy.common.utils.poi.ExcelUtil;
import com.jcfy.framework.web.page.TableDataInfo;

/**
 * 账户收支明细Controller
 *
 * @author jiangfeng
 * @date 2020-08-05
 */
@RestController
@RequestMapping("/module/accountDetail" )
public class TAccountDetailController extends BaseController {
    @Autowired
    private ITAccountDetailService tAccountDetailService;

    /**
     * 查询账户收支明细列表
     */
    @PreAuthorize("@ss.hasPermi('module:accountDetail:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(TAccountDetail tAccountDetail) {
        startPage();
        List<TAccountDetail> list = tAccountDetailService.selectTAccountDetailList(tAccountDetail);
        return getDataTable(list);
    }

    /**
     * 导出账户收支明细列表
     */
    @PreAuthorize("@ss.hasPermi('module:accountDetail:export')" )
    @Log(title = "账户收支明细" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(TAccountDetail tAccountDetail) {
        List<TAccountDetail> list = tAccountDetailService.selectTAccountDetailList(tAccountDetail);
        ExcelUtil<TAccountDetail> util = new ExcelUtil<TAccountDetail>(TAccountDetail. class);
        return util.exportExcel(list, "detail" );
    }

    /**
     * 获取账户收支明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:accountDetail:query')" )
    @GetMapping(value = "/{adId}" )
    public AjaxResult getInfo(@PathVariable("adId" ) Long adId) {
        return AjaxResult.success(tAccountDetailService.selectTAccountDetailById(adId));
    }

    /**
     * 新增账户收支明细
     */
    @PreAuthorize("@ss.hasPermi('module:accountDetail:add')" )
    @Log(title = "账户收支明细" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAccountDetail tAccountDetail) {
        return toAjax(tAccountDetailService.insertTAccountDetail(tAccountDetail));
    }

    /**
     * 修改账户收支明细
     */
    @PreAuthorize("@ss.hasPermi('module:accountDetail:edit')" )
    @Log(title = "账户收支明细" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAccountDetail tAccountDetail) {
        return toAjax(tAccountDetailService.updateTAccountDetail(tAccountDetail));
    }

    /**
     * 删除账户收支明细
     */
    @PreAuthorize("@ss.hasPermi('module:accountDetail:remove')" )
    @Log(title = "账户收支明细" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{adIds}" )
    public AjaxResult remove(@PathVariable Long[] adIds) {
        return toAjax(tAccountDetailService.deleteTAccountDetailByIds(adIds));
    }
}
